<%@page import="itsm.isperp.framework.core.context.ContextHolder"%><%@page
	import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<script type="text/javascript" src="js/libs/forms/uploader/plupload.js"></script>
<script type="text/javascript"
	src="js/libs/forms/uploader/plupload.gears.js"></script>
<script type="text/javascript"
	src="js/libs/forms/uploader/plupload.silverlight.js"></script>
<script type="text/javascript"
	src="js/libs/forms/uploader/plupload.flash.js"></script>
<script type="text/javascript"
	src="js/libs/forms/uploader/plupload.browserplus.js"></script>
<script type="text/javascript"
	src="js/libs/forms/uploader/plupload.html4.js"></script>
<script type="text/javascript"
	src="js/libs/forms/uploader/plupload.html5.js"></script>
<script type="text/javascript">
function _$(id) {${model.id}
	return document.getElementById(id);
}


var addfile = false;

var uploader = new plupload.Uploader({
	runtimes : 'gears,html5,flash,silverlight,browserplus',
	browse_button : 'pickfiles',
	container : 'container',
	max_file_size : '10mb',
	url : "<%=ContextHolder.getWebServerName()%>fileUpload?sourceId=${id}${model.id}",
		flash_swf_url : '<%=ContextHolder.getWebServerName()%>js/libs/forms/uploader/plupload.flash.swf',
		filters : [ {
			title : "选择文件",
			extensions : "jpg,gif,png,jpeg,txt,doc,docx,xls,xlsx,ppt,pptx,pdf,zip,rar"
		} ]
	});

	uploader.bind('Init', function(up, params) {
		
	});

	uploader.init();
	uploader.bind('UploadComplete', function(up, files) {
		uploadfinished = true;
	});

	uploader.bind('FilesAdded', function(up, files) {
		for ( var i in files) {
			_$('filelist').innerHTML += '<div id="' + files[i].id + '">' + files[i].name + ' (' + plupload.formatSize(files[i].size) + ') <b></b>&nbsp;<span class="ufp"><a onclick="delAttach(\'' + files[i].id + '\')">删除</a></span></div>';
		}
		addfile = true;
	});

	uploader.bind('UploadComplete', function(up, file) {
		doSubmit();
	});

	uploader.bind('UploadProgress', function(up, file) {
		$("#" + file.id + " span").html(file.percent+"%");

	});

	function delAttach(id) {
		$("#" + id).remove();
		uploader.removeFile(uploader.getFile(id));
	}
</script>